package thread;

/**
 * 当一个线程调用sleep方法处于睡眠阻塞的过程中，此时该线程的interrupt方法被调用时
 * 会中断其睡眠阻塞，此时该方法会抛出中断异常
 */
public class SleepDemo2 {
    public static void main(String[] args) {
        Thread lin = new Thread("妮"){
            public void run(){
                System.out.println(getName()+"把西瓜洗了");
                try {
                    Thread.sleep(1000000);
                } catch (InterruptedException e) {
                    System.out.println(getName()+"你干啥呢？还吃不不了");
                }
                System.out.println(getName()+"，你醒了");

            }
        };

        Thread huang = new Thread("弟"){
            public void run(){
                System.out.println(getName()+"洗刷刷洗刷刷");
                for (int i = 0; i < 5; i++){
                    System.out.println(getName()+"我是一个臭皮匠");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    }
                }
                System.out.println("咣当！");
                System.out.println(getName()+"妮，西瓜烂了");
                //interrupt：中断
                lin.interrupt();
            }
        };
        lin.start();
        huang.start();
    }
}
